package com.kjhxtc.restfulrunner;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Console;

/**
 * @author 杜神
 * @version 1.0
 * @since 2022/3/16 12:50
 */
public class Log {
    public static boolean IS_INFO = false;
    public static boolean IS_DEBUG = false;
    public static boolean IS_TRACE = false;

    public static void log(String msg, Object... params) {
        Console.log(msg, params);
    }

    public static void info(String msg, Object... params) {
        if (IS_INFO) {
            Console.log(msg, params);
        }
    }

    public static void debug(String msg, Object... params) {
        if (IS_DEBUG) {
            Console.log(msg, params);
        }
    }

    public static void trace(String msg, Object... params) {
        if (IS_TRACE) {
            Console.log(DateUtil.now()+" ["+Thread.currentThread().getName()+"] "+msg, params);
        }
    }

    public static void error(String msg, Object... params) {
        Console.log(msg, params);
    }

    public static void warn(String msg, Object... params) {
        Console.error(msg, params);
    }

    public static void error(String msg, Throwable e) {
        Console.error(msg + "\n" + e.toString());
    }
}
